/**************************************************************************(C)*
 *
 *  This file is part of the GreenHills project
 *  Copyright (C) 2009  Tieto Corporation
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  Not for commmercial use. Only with Tieto permission.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************(C)*/

#pragma once

#include "../core/room.h"
#include "../core/iroomitem.h"
#include "../core/iserver.h"
#include <list>

namespace greenhills {
namespace server {

/**
  * @brief Greenhills server room object represenation
  *
  * Provides server specific functionality of room object.
  * Holds list of joined clients and room password.
  */
class CRoom : public greenhills::core::CRoom
{
public:
    typedef std::list<greenhills::core::CClientId> CRoomItemClients;
    typedef CRoomItemClients::const_iterator ClientsConstIterator;
    typedef CRoomItemClients::iterator ClientsIterator;

public:
    CRoom(const greenhills::core::CRoomId &pRoomId,
            const std::string &pRoomName, const std::string &pPassword);

public:
    bool isPasswordValid(const std::string &pPassword) const;

public:
    void joinClient(const greenhills::core::CClientId &pClientId);
    void removeClient(const greenhills::core::CClientId &pClientId);
    virtual ClientsIterator clientsBegin();
    virtual ClientsIterator clientsEnd();

private:
    CRoomItemClients mClients;
    std::string mPassword;
};

} //namespace server
} //namespace greenhills
